package cn.zhage.aimin.mcp.server.controller;

/*
 *
 * @author 渣哥
 */

import cn.zhage.aimin.mcp.server.service.TableInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/test")
@RequiredArgsConstructor
public class TestController {

    private final TableInfoService tableInfoService;


    @GetMapping("/tableNames")
    public String list() {
        List<Map<String, String>> tableNames = tableInfoService.getTableNames();
        System.out.println(tableNames);
        return "ok";
    }


    @GetMapping("/fieldListByTableName")
    public String fieldListByTableName(String tableName) {
        List<Map<String, String>> fieldListByTableName = tableInfoService.getFieldListByTableName(tableName);
        System.out.println(fieldListByTableName);
        return "ok";
    }

    @GetMapping("/exec")
    public String exec(String sql) {
        List<Map<String, Object>> maps = tableInfoService.executeSql(sql);
        System.out.println(maps);
        return "ok";
    }
}
